#ifndef __BSP_I2C_H__
#define __BSP_I2C_H__

#define eI2C1_SPEED SP100K
#define eI2C2_SPEED SP100K

#include <stdint.h>
#include <stdbool.h>

#define GPIOB_MODER_Addr (GPIOB + 0x00)  // GPIOB(MODER)地址
#define GPIOB_MODER_Addr2 (GPIOB + 0x04) // GPIOB(MODER)地址

#define GPIO_PBmode(n) BIT_ADDR(GPIOB_MODER_Addr, n)   // 设置IO口工作模式
#define GPIO_PBmode2(n) BIT_ADDR(GPIOB_MODER_Addr2, n) // 设置IO口工作模式
#define GPIO_PEmode(n) BIT_ADDR(GPIOE_MODER_Addr, n)   // 设置IO口工作模式

typedef enum
{
    mI2_eep = 0U,
    mI2_ads1,
    mI2_ads2,
    mI2_ads3,
    mI2_ads4,
} I2C_PORT;

typedef enum
{
    SP50K = 50000,
    SP100K = 100000,
    SP200K = 200000,
    SP400K = 400000
} Speed_Typedef;

typedef struct
{
    void (*finit)(I2C_PORT);
    unsigned char (*feepRead)(I2C_PORT, unsigned char, unsigned short, unsigned char *, unsigned short);
    unsigned char (*feepWrite)(I2C_PORT, unsigned char, unsigned short, unsigned char *, unsigned short);
    unsigned char (*fadsRead)(I2C_PORT, unsigned char, unsigned char *, unsigned short);
    unsigned char (*fadsWrite)(I2C_PORT, unsigned char, unsigned char *, unsigned short);
} dv_I2C_TypeDef;

extern dv_I2C_TypeDef dv_I2C;

void init_dv_I2C(void);

#endif
